package com.gy.assistant.ui.chat.base.adapter;

import android.app.Activity;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

import com.gy.assistant.entity.MessageInfo;
import com.gy.assistant.ui.chat.base.adapter.holder.ChatLeftViewHolder;

public class CombineMessageAdapter extends RecyclerView.Adapter{
    private OnItemClickListener onItemClickListener;
    private List<MessageInfo> messageInfoList = new ArrayList<>();
    private Activity activity;

    public CombineMessageAdapter(Activity activity){
        this.activity = activity;
    }
    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        RecyclerView.ViewHolder viewHolder = new ChatLeftViewHolder(parent, onItemClickListener, activity);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        holder.itemView.setTag(position);
        MessageInfo messageInfo = messageInfoList.get(position);
        ChatLeftViewHolder chat = (ChatLeftViewHolder) holder;
        // todo add avatar logic
        chat.setMessageInfo(messageInfo,false,"");
    }

    @Override
    public int getItemCount() {
        return messageInfoList.size();
    }

    public void setOnItemClickListener(OnItemClickListener clickListener){
        this.onItemClickListener = clickListener;
    }
    public void setMessageList(ArrayList<MessageInfo> list){
        messageInfoList = list;
    }
}
